<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
        Object.create方法解析
      */
      /* const obj = Object.create(null, {
        name: {
          //某个属性的值
          value: "laowang",
          //控制当前属性是否可以被修改,默认是false
          writable: false,
          //控制当前属性是否可以被枚举出来  默认false
          enumerable: false,
          //控制特征是否可以被修改,或者当前属性是否可以被删除 默认false
          configurable: false,
        },
      });

      console.log("obj", obj);

      console.log("修改obj的name值", (obj.name = "xiaoli"), obj);

      for (let key in obj) {
        console.log("枚举", key);
      }

      console.log("删除obj的name值", delete obj.name, obj); */





      //创建一个干净的对象 并给他的name属性添加一些特性
      const obj = Object.create(null , {
        name:{
          value: "laoliu",
          writable: true, //可修改
          enumerable: true, //可枚举(属性名就不虚了)
          configurable: true, //可删除
        }
      })


      //修改
      obj.name = "laowang"

      //枚举
      for (let key in obj){
        console.log(key);
      }

      //删除
      delete obj.name

      console.log(obj , "obj");

      





    </script>
  </body>
</html>
